using System;
using System.Collections;
using System.IO;

using Game.Input;
using Game.Output;

namespace Game.Data
{
	public static class CData
	{
		private static C2FieldData	m_paths;
		private static C2FieldData	m_settings;
		private static C2FieldData	m_texts;
		
		private static ArrayList	m_tilesets;
		
		public static void Initialize()
		{
			CConsole.ReportClassInit(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name);
			
			m_paths = new C2FieldData(CProgram.ROOT_DIR + @"data\strings\paths.txt");
			m_paths.Add("FONTS",	CProgram.ROOT_DIR + @"data\fonts\");
			m_paths.Add("TILESETS",	CProgram.ROOT_DIR + @"data\tilesets\");
			
			m_settings = new C2FieldData(CProgram.ROOT_DIR + @"data\strings\settings.txt");
			m_settings.Add("IS_DEBUG_MODE",		"1"		);
			m_settings.Add("FRAMES_PER_SECOND",	"20"	);
			m_settings.Add("MAP_SIZE_X",		"8"		);
			m_settings.Add("MAP_SIZE_Y",		"8"		);
			
			m_texts = new C2FieldData(CProgram.ROOT_DIR + @"data\strings\texts.txt");
			m_texts.Add("GAME_TITLE", "Traffic and Transport Simulator [alpha 1.0]");	
		
			InitializeTilesets();
		}
		
		private static void InitializeTilesets()
		{
			CTileset	tileset;
			string		name;
			
			m_tilesets = new ArrayList();
			string[] paths = Directory.GetFiles(CProgram.ROOT_DIR + @"data\tilesets\");
			
			foreach (string path in paths)
			{
				if (path.Substring(path.Length - 4, 4) != ".bmp")
					continue;
				
				name = path.Substring(path.LastIndexOf('\\') + 1);
				name = name.Substring(0, name.Length - 4);
				
				tileset = new CTileset(name);
				m_tilesets.Add(tileset);
			}	
		}
		
		#region properties
		
		public static C2FieldData Paths
		{
			get {
				return m_paths;
			}
		}
		
		public static C2FieldData Settings
		{
			get {
				return m_settings;
			}
		}
		
		public static C2FieldData Texts
		{
			get {
				return m_texts;
			}
		}
		
		#endregion
		
	}
}
